package acwing._1_1AlgorithmBasic._3SearchGraph;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._3SearchGraph
 * @File : Q0853.java
 * @Author : WangRuoyu
 * @Date 2023/4/2 16:58
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Q0853 {
    static int n;
    static int m;
    static int k;
    static int[][] edge;
    static int[] last;

    static int[] bellmanFord(int x) {
        int[] res = new int[n + 1];
        Arrays.fill(res, 0x3f3f3f3f);
        res[x] = 0;
        for (int i = 0; i < k; i++) {
            System.arraycopy(res, 0, last, 0, n + 1);
            for (int j = 0; j < m; j++) {
                int a = edge[j][0];
                int b = edge[j][1];
                int w = edge[j][2];
                res[b] = Math.min(res[b], last[a] + w);
            }
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        n = Integer.parseInt(words[0]);
        m = Integer.parseInt(words[1]);
        k = Integer.parseInt(words[2]);
        edge = new int[m][3];
        last = new int[n + 1];
        for (int i = 0; i < m; i++) {
            words = br.readLine().split(" ");
            edge[i][0] = Integer.parseInt(words[0]);
            edge[i][1] = Integer.parseInt(words[1]);
            edge[i][2] = Integer.parseInt(words[2]);
        }

        int[] res = bellmanFord(1);

        if (res[n] > 0x3f3f3f3f / 2) {
            System.out.println("impossible");
        } else {
            System.out.println(res[n]);
        }
    }
}
